rm(list=ls())
library(tidyverse)
library(gridExtra)
# read in frame
df <- read.csv("/Users/erollkuhn/Dropbox (Personal)/Refugee Context Project/Clean Code V8/4.Main Models/Plot/Clean_Combined_Disagg.csv")
# pre-processing
df <- data.frame(df)
df$facet_lab <- ifelse(df$IV=="% Foreign-Born",1,
ifelse(df$IV=="% Non-EU",2,
ifelse(df$IV=="% Co-National",3,NA)))
df$facet_lab <- factor(df$facet_lab,
levels = c(1,2,3),
labels = c("% Foreign-Born",
"% Non-EU Foreign-Born",
"% Co-National"))
ggplot(df) +
geom_pointrange(aes(x=Numeric,y=Coef,ymin=Lower95,ymax=Upper95,shape=Subsample),lwd=0.25) +
geom_pointrange(aes(x=Numeric,y=Coef,ymin=Lower90,ymax=Upper90,shape=Subsample),lwd=0.5) +
theme_bw() +
facet_wrap(~facet_lab) +
xlim(1,2) +
geom_hline(yintercept = 0,lty=2) +
ylab("Effect on Demographic Context on Feeling Welcome") +
xlab("") +
theme(legend.direction = "horizontal",
legend.position = "bottom",
panel.grid.major.x = element_blank(),
panel.grid.minor = element_blank(),
panel.grid.major = element_blank(),
axis.text.x = element_text(size=8, angle = 15, hjust = 1),
axis.text.y = element_text(size=8),
legend.text = element_text(size = 12)) +
scale_x_discrete()
png("/Users/erollkuhn/Dropbox (Personal)/Refugee Context Project/Clean Code V8/4.Main Models/Plot/Figure/CoefPlot_Disagg_OLS.png",
width=10,height=12,units='in',res=300)
ggplot(df) +
geom_pointrange(aes(x=Numeric,y=Coef,ymin=Lower95,ymax=Upper95,shape=Subsample),lwd=0.25) +
geom_pointrange(aes(x=Numeric,y=Coef,ymin=Lower90,ymax=Upper90,shape=Subsample),lwd=0.5) +
theme_bw() +
facet_wrap(~facet_lab) +
xlim(1,2) +
geom_hline(yintercept = 0,lty=2) +
ylab("Effect on Demographic Context on Feeling Welcome") +
xlab("") +
theme(legend.direction = "horizontal",
legend.position = "bottom",
panel.grid.major.x = element_blank(),
panel.grid.minor = element_blank(),
panel.grid.major = element_blank(),
axis.text.x = element_text(size=8, angle = 15, hjust = 1),
axis.text.y = element_text(size=8),
legend.text = element_text(size = 12)) +
scale_x_discrete()
dev.off()
png("/Users/erollkuhn/Dropbox (Personal)/Refugee Context Project/Clean Code V8/4.Main Models/Plot/Figure/CoefPlot_Disagg_OLS.png",
width=10,height=6,units='in',res=300)
ggplot(df) +
geom_pointrange(aes(x=Numeric,y=Coef,ymin=Lower95,ymax=Upper95,shape=Subsample),lwd=0.25) +
geom_pointrange(aes(x=Numeric,y=Coef,ymin=Lower90,ymax=Upper90,shape=Subsample),lwd=0.5) +
theme_bw() +
facet_wrap(~facet_lab) +
xlim(1,2) +
geom_hline(yintercept = 0,lty=2) +
ylab("Effect on Demographic Context on Feeling Welcome") +
xlab("") +
theme(legend.direction = "horizontal",
legend.position = "bottom",
panel.grid.major.x = element_blank(),
panel.grid.minor = element_blank(),
panel.grid.major = element_blank(),
axis.text.x = element_text(size=8, angle = 15, hjust = 1),
axis.text.y = element_text(size=8),
legend.text = element_text(size = 12)) +
scale_x_discrete()
dev.off()
rm(list=ls())
library(tidyverse)
library(gridExtra)
# read in frame
df <- read.csv("/Users/erollkuhn/Dropbox (Personal)/Refugee Context Project/Clean Code V7/4a.Predicted Values/Output/CleanPredictions_forPlot_v2.csv")
rm(list=ls())
library(tidyverse)
library(gridExtra)
# read in frame
df <- read.csv("/Users/erollkuhn/Dropbox (Personal)/Refugee Context Project/Clean Code V7/4a.Predicted Values/Output/CleanPredictions_forPlot_v2.csv")
df$facet_lab <- ifelse(df$Var=="% Foreign-Born",1,
ifelse(df$Var=="% Non-EU Foreign-Born",2,
#ifelse(df$Var=="% from Arabic-Speaking Country",3,
ifelse(df$Var=="% Co-National (Syrians Only)",3,NA)))
df$Var
df$facet_lab <- factor(df$facet_lab,
levels = c(1,2,3),
labels = c("% Foreign-Born",
"% Non-EU Foreign-Born",
"% from Arabic-Speaking Countries",
"% Co-National (Syrians Only)"))
df$facet_lab
rm(list=ls())
library(tidyverse)
library(gridExtra)
# read in frame
df <- read.csv("/Users/erollkuhn/Dropbox (Personal)/Refugee Context Project/Clean Code V8/4a.Predicted Values/Output/CleanPredictions_forPlot_v2.csv")
df$facet_lab <- ifelse(df$Var=="% Foreign-Born",1,
ifelse(df$Var=="% Non-EU Foreign-Born",2,
#ifelse(df$Var=="% from Arabic-Speaking Country",3,
ifelse(df$Var=="% Co-National (Syrians Only)",3,NA)))
df$Var
df$facet_lab <- factor(df$facet_lab,
levels = c(1,2,3),
labels = c("% Foreign-Born",
"% Non-EU Foreign-Born",
"% from Arabic-Speaking Countries",
"% Co-National (Syrians Only)"))
df$facet_lab
rm(list=ls())
library(tidyverse)
library(gridExtra)
# read in frame
df <- read.csv("/Users/erollkuhn/Dropbox (Personal)/Refugee Context Project/Clean Code V8/4a.Predicted Values/Output/CleanPredictions_forPlot_v2.csv")
df <- subset(df, df$Var!="% from Arabic-Speaking Country")
df$facet_lab <- ifelse(df$Var=="% Foreign-Born",1,
ifelse(df$Var=="% Non-EU Foreign-Born",2,
#ifelse(df$Var=="% from Arabic-Speaking Country",3,
ifelse(df$Var=="% Co-National (Syrians Only)",3,NA)))
df$facet_lab <- factor(df$facet_lab,
levels = c(1,2,3),
labels = c("% Foreign-Born",
"% Non-EU Foreign-Born",
"% Co-National (Syrians Only)"))
ggplot(df) +
geom_line(aes(x=Value,y=Pred),size=1) +
geom_smooth(aes(x=Value,y=bottom95),color="red",size=0.5,lty=3) +
geom_smooth(aes(x=Value,y=top95),color="red",size=0.5,lty=3) +
geom_col(aes(x=Value,y=prop_val)) +
facet_wrap(~facet_lab) +
theme_bw() +
geom_hline(yintercept = 0, lty = 2) +
geom_hline(yintercept = 1, lty = 2) +
ylim(-0.05,1.20) +
xlab("Value of Demographic Variable (% of County Population)") +
ylab("Predicted Value on Welcomeness Index") +
theme(legend.position = "none",
panel.grid.major.x = element_blank(),
panel.grid.minor = element_blank(),
panel.grid.major = element_blank())
setwd("/Users/erollkuhn/Dropbox (Personal)/Refugee Context Project/Clean Code V8/4a.Predicted Values/Output/Figures")
png("Dem_Predictions.png",
width=10,height=6,units='in',res=300)
ggplot(df) +
geom_line(aes(x=Value,y=Pred),size=1) +
geom_smooth(aes(x=Value,y=bottom95),color="red",size=0.5,lty=3) +
geom_smooth(aes(x=Value,y=top95),color="red",size=0.5,lty=3) +
geom_col(aes(x=Value,y=prop_val)) +
facet_wrap(~facet_lab) +
theme_bw() +
geom_hline(yintercept = 0, lty = 2) +
geom_hline(yintercept = 1, lty = 2) +
ylim(-0.05,1.20) +
xlab("Value of Demographic Variable (% of County Population)") +
ylab("Predicted Value on Welcomeness Index") +
theme(legend.position = "none",
panel.grid.major.x = element_blank(),
panel.grid.minor = element_blank(),
panel.grid.major = element_blank())
dev.off()
